package com.dianpingmedia.common.utils;

import com.dianpingmedia.simulate.model.SimulateMaterialEntity;

import java.util.LinkedList;
import java.util.List;

public class MaterialUtil {

    private static final List<SimulateMaterialEntity> MATERIALS = new LinkedList<SimulateMaterialEntity>() {
        {

            SimulateMaterialEntity material1 = newFirstMaterial();
            SimulateMaterialEntity material2 = newSecondMaterial();
            SimulateMaterialEntity material3 = newThirdMaterial();
            SimulateMaterialEntity material4 = newFourthMaterial();
            add(material1);
            add(material2);
            add(material3);
            add(material4);
        }
    };

    private static SimulateMaterialEntity newFirstMaterial() {
        SimulateMaterialEntity material = new SimulateMaterialEntity();
        material.setCreative_type(1);
        material.setAdTracking(null);
        material.setFile_md5("63A135631F750DF3497AE76BC6F88ED4");
        material.setMaterialSrc("http://192.168.1.106:20000/Admin/pic/png/png%20(1).png");
        material.setMaterial_width(1920);
        material.setMaterial_height(1080);
        material.setDuration(15);
        return material;
    }


    private static SimulateMaterialEntity newSecondMaterial() {
        SimulateMaterialEntity material = new SimulateMaterialEntity();
        material.setCreative_type(2);
        material.setAdTracking(null);
        material.setFile_md5("CAF9F246D36D74D739AF9355F4B094A3");
        material.setMaterialSrc("http://192.168.1.106:20000/Admin/video/google.mp4");
        material.setMaterial_width(1280);
        material.setMaterial_height(720);
        material.setDuration(30);
        return material;
    }


    private static SimulateMaterialEntity newThirdMaterial() {
        SimulateMaterialEntity material = new SimulateMaterialEntity();
        material.setCreative_type(1);
        material.setAdTracking(null);
        material.setFile_md5("A28E4120C6841B5744D8EFA37BA47ADA");
        material.setMaterialSrc("http://192.168.1.106:20000/Admin/pic/png/png%20(2).png");
        material.setMaterial_width(1920);
        material.setMaterial_height(1080);
        material.setDuration(15);
        return material;
    }


    private static SimulateMaterialEntity newFourthMaterial() {
        SimulateMaterialEntity material = new SimulateMaterialEntity();
        material.setCreative_type(2);
        material.setAdTracking(null);
        material.setFile_md5("1CFE020AFEA36684836CF73B39B49875");
        material.setMaterialSrc("http://192.168.1.106:20000/Admin/video/mp4/1080p/%e4%b8%89%e6%98%9fGALAXY%20Tab%e5%b9%b3%e6%9d%bf%e7%94%b5%e8%84%91%e5%b9%bf%e5%91%8a-1080p.mp4");
        material.setMaterial_width(1920);
        material.setMaterial_height(1080);
        material.setDuration(30);
        return material;
    }


    public static SimulateMaterialEntity getMaterial() {
        int random = (int) (Math.random() * MATERIALS.size() + 2);
        SimulateMaterialEntity material = null;
        try {
            return MATERIALS.get(random);
        } catch (Exception e) {
            return null;
        }
    }
}
